home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Utilities / ttf2pt1PPC / src / pt1.h < prev    next >
C/C++ Source or Header  |  2001-05-24  |  8KB  |  235 lines

  1. /*
  2.  * see COPYRIGHT
  3.  */
  4.  
  5.  
  6. /* glyph entry, one drawing command */
  7. typedef struct gentry {
  8.     /* this list links all GENTRYs of a GLYPH sequentially */
  9.     struct gentry  *next;    /* double linked list */
  10.     struct gentry  *prev;
  11.  
  12.     /* this list links all GENTRYs of one contour - 
  13.      * of types GE_LINE and GE_CURVE only
  14.      * bkwd is also reused: in the very first entry (normally
  15.      * of type GE_MOVE) it points to g->entries
  16.      */
  17.     struct gentry  *cntr[2]; /* double-linked circular list */
  18. /* convenience handles */
  19. #define bkwd cntr[0]
  20. #define frwd cntr[1]
  21.  
  22.     union {
  23.         struct {
  24.             int  val[2][3];    /* integer values */
  25.         } i;
  26.         struct {
  27.             double  val[2][3];    /* floating values */
  28.         } f;
  29.     } points; /* absolute values, NOT deltas */
  30. /* convenience handles */
  31. #define ipoints    points.i.val
  32. #define fpoints    points.f.val
  33. #define ixn ipoints[0]
  34. #define iyn ipoints[1]
  35. #define fxn fpoints[0]
  36. #define fyn fpoints[1]
  37. #define ix1    ixn[0]
  38. #define ix2 ixn[1]
  39. #define ix3 ixn[2]
  40. #define iy1    iyn[0]
  41. #define iy2 iyn[1]
  42. #define iy3 iyn[2]
  43. #define fx1    fxn[0]
  44. #define fx2 fxn[1]
  45. #define fx3 fxn[2]
  46. #define fy1    fyn[0]
  47. #define fy2 fyn[1]
  48. #define fy3 fyn[2]
  49.  
  50.     char            flags; 
  51. #define GEF_FLOAT    0x02 /* entry contains floating point data */
  52.  
  53.     unsigned char    dir; /* used to temporarily store the values for
  54.                 * the directions of the ends of curves */
  55. /* front end */
  56. #define CVDIR_FUP    0x02    /* goes over the line connecting the ends */
  57. #define CVDIR_FEQUAL    0x01    /* coincides with the line connecting the
  58.                  * ends */
  59. #define CVDIR_FDOWN    0x00    /* goes under the line connecting the ends */
  60. #define CVDIR_FRONT    0x0F    /* mask of all front directions */
  61. /* rear end */
  62. #define CVDIR_RSAME    0x30    /* is the same as for the front end */
  63. #define CVDIR_RUP    0x20    /* goes over the line connecting the ends */
  64. #define CVDIR_REQUAL    0x10    /* coincides with the line connecting the
  65.                  * ends */
  66. #define CVDIR_RDOWN    0x00    /* goes under the line connecting the ends */
  67. #define CVDIR_REAR    0xF0    /* mask of all rear directions */
  68.  
  69.     signed char     stemid; /* connection to the substituted stem group */
  70.     char            type;
  71. #define GE_HSBW    'B'
  72. #define GE_MOVE 'M'
  73. #define GE_LINE 'L'
  74. #define GE_CURVE 'C'
  75. #define GE_PATH 'P'
  76. }               GENTRY;
  77.  
  78. /* stem structure, describes one [hv]stem  */
  79. /* acually, it describes one border of a stem */
  80. /* the whole stem is a pair of these structures */
  81.  
  82. typedef struct stem {
  83.     short           value;    /* value of X or Y coordinate */
  84.     short           origin;    /* point of origin for curve stems */
  85.     GENTRY         *ge; /* entry that has (value, origin) as its first dot */
  86.         /* also for all the stems the couple (value, origin)
  87.          * is used to determine whether a stem is relevant for a
  88.          * line, it's considered revelant if this tuple is
  89.          * equal to any of the ends of the line.
  90.          * ge is also used to resolve ambiguity if there is more than
  91.          * one line going through certain pointi, it is used to 
  92.          * distinguish these lines.
  93.          */
  94.      
  95.     short           from, to;    /* values of other coordinate between
  96.                      * which this stem is valid */
  97.  
  98.     short           flags;
  99.     /* ordering of ST_END, ST_FLAT, ST_ZONE is IMPORTANT for sorting */
  100. #define ST_END        0x01    /* end of line, lowest priority */
  101. #define ST_FLAT        0x02    /* stem is defined by a flat line, not a
  102.                  * curve */
  103. #define ST_ZONE        0x04    /* pseudo-stem, the limit of a blue zone */
  104. #define ST_UP        0x08    /* the black area is to up or right from
  105.                  * value */
  106. #define ST_3        0x20    /* first stem of [hv]stem3 */
  107. #define ST_BLUE        0x40    /* stem is in blue zone */
  108. #define ST_TOPZONE    0x80    /* 1 - top zone, 0 - bottom zone */
  109. #define ST_VERT     0x100    /* vertical stem (used in substitutions) */
  110. }               STEM;
  111.  
  112. #define MAX_STEMS    2000    /* we can't have more stems than path
  113.                  * elements (or hope so) */
  114. #define NSTEMGRP    50    /* maximal number of the substituted stem groups */
  115.  
  116. /* structure for economical representation of the
  117.  * substituted stems
  118.  */
  119.  
  120. typedef struct stembounds {
  121.     short low; /* low bound */
  122.     short high; /* high bound */
  123.     char isvert; /* 1 - vertical, 0 - horizontal */
  124.     char already; /* temp. flag: is aleready included */
  125. } STEMBOUNDS;
  126.  
  127. struct kern {
  128.     unsigned id; /* ID of the second glyph */
  129.     int val; /* kerning value */
  130. };
  131.  
  132. typedef struct contour {
  133.     short           ymin, xofmin;
  134.     short           inside;    /* inside which contour */
  135.     char            direction;
  136. #define DIR_OUTER 1
  137. #define DIR_INNER 0
  138. }               CONTOUR;
  139.  
  140. typedef struct glyph {
  141.     int             char_no;/* Encoding of glyph */
  142.     int             orig_code;/* code of glyph in the font's original encoding */
  143.     char           *name;    /* Postscript name of glyph */
  144.     int             xMin, yMin, xMax, yMax;    /* values from TTF dictionary */
  145.     int             lsb; /* left sidebearing */
  146.     int             ttf_pathlen; /* total length of TTF paths */
  147.     short           width;
  148.     short           flags;
  149. #define GF_USED    0x0001        /* whether is this glyph used in T1 font */
  150. #define GF_FLOAT 0x0002        /* thys glyph contains floating point entries */
  151.  
  152.     GENTRY         *entries;/* doube linked list of entries */
  153.     GENTRY         *lastentry;    /* the last inserted entry */
  154.     GENTRY         *path;    /* beggining of the last path */
  155.     int             oldwidth; /* actually also scaled */
  156.     int             scaledwidth;
  157. #define    MAXLEGALWIDTH    10000 
  158.  
  159.     struct kern    *kern; /* kerning data */
  160.     int             kerncount; /* number of kerning pairs */
  161.     int             kernalloc; /* for how many pairs we have space */
  162.  
  163.     STEM           *hstems; /* global horiz. and vert. stems */
  164.     STEM           *vstems;
  165.     int             nhs, nvs;    /* numbers of stems */
  166.  
  167.     STEMBOUNDS     *sbstems; /* substituted stems for all the groups */
  168.     short          *nsbs; /* indexes of the group ends in the common array */
  169.     int             nsg; /* actual number of the stem groups */
  170.     int             firstsubr; /* first substistuted stems subroutine number */
  171.  
  172.     CONTOUR        *contours;    /* it is not used now */
  173.     int             ncontours;
  174.  
  175.     int             rymin, rymax;    /* real values */
  176.     /* do we have flat surfaces on top/bottom */
  177.     char            flatymin, flatymax;
  178.  
  179. }               GLYPH;
  180.  
  181. extern int      stdhw, stdvw;    /* dominant stems widths */
  182. extern int      stemsnaph[12], stemsnapv[12];    /* most typical stem width */
  183.  
  184. extern int      bluevalues[14];
  185. extern int      nblues;
  186. extern int      otherblues[10];
  187. extern int      notherb;
  188. extern int      bbox[4];    /* the FontBBox array */
  189. extern double   italic_angle;
  190.  
  191. extern GLYPH   *glyph_list;
  192. extern int    encoding[];    /* inverse of glyph[].char_no */
  193.  
  194. /* prototypes of functions */
  195. void rmoveto( int dx, int dy);
  196. void rlineto( int dx, int dy);
  197. void rrcurveto( int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
  198. void assertpath( GENTRY * from, char *file, int line, char *name);
  199.  
  200. void fg_rmoveto( GLYPH * g, double x, double y);
  201. void ig_rmoveto( GLYPH * g, int x, int y);
  202. void fg_rlineto( GLYPH * g, double x, double y);
  203. void ig_rlineto( GLYPH * g, int x, int y);
  204. void fg_rrcurveto( GLYPH * g, double x1, double y1,
  205.     double x2, double y2, double x3, double y3);
  206. void ig_rrcurveto( GLYPH * g, int x1, int y1,
  207.     int x2, int y2, int x3, int y3);
  208. void g_closepath( GLYPH * g);
  209.  
  210. void pathtoint( GLYPH *g);
  211. void ffixquadrants( GLYPH *g);
  212. void flattencurves( GLYPH * g);
  213. int checkcv( GENTRY * ge, int dx, int dy);
  214. void iclosepaths( GLYPH * g);
  215. void fclosepaths( GLYPH * g);
  216. void smoothjoints( GLYPH * g);
  217. void buildstems( GLYPH * g);
  218. void fstraighten( GLYPH * g);
  219. void istraighten( GLYPH * g, int zigonly);
  220. void isplitzigzags( GLYPH * g);
  221. void fsplitzigzags( GLYPH * g);
  222. void fforceconcise( GLYPH * g);
  223. void iforceconcise( GLYPH * g);
  224. void reversepathsfromto( GENTRY * from, GENTRY * to);
  225. void reversepaths( GLYPH * g);
  226. void dumppaths( GLYPH * g, GENTRY *start, GENTRY *end);
  227. void print_glyph( int glyphno);
  228. int print_glyph_subs( int glyphno, int startid);
  229. void print_glyph_metrics( int code, int glyphno);
  230. void findblues(void);
  231. void stemstatistics(void);
  232. void docorrectwidth(void);
  233. void addkernpair( unsigned id1, unsigned id2, int unscval);
  234. void print_kerning( FILE *afm_file);
  235.